﻿

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;

using OpenCvSharp;

using PaddleOCRSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 颜色映射
    /// </summary>
    [Filter("颜色映射",FilterType.Algorithm)]
    public class AlgorithmApplyColorMap : FilterBase
    {
        /// <summary>
        /// 类型
        /// </summary>
        [InputParameter("类型")]
        public ColormapTypes ColormapType { get; set; }
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Cv2.ApplyColorMap(mat,mat, ColormapType);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, mat);

        }
    }
    /// <summary>
    /// 模糊过滤器
    /// </summary>
    [Filter("模糊算法",FilterType.Algorithm)]
    public class AlgorithmBlur : FilterBase
    {

        /// <summary>
        /// 尺寸
        /// </summary>
        [InputParameter("尺寸")]
        public CVSize KSize { get; set; }=new CVSize() { Height=5,Width=5};
        /// <summary>
        /// 附着点
        /// </summary>
        [InputParameter("附着点")]
        public CVPoint Anchor { get; set; } = new CVPoint { X = 1, Y = 1 };
        /// <summary>
        /// 边界类型
        /// </summary>
        [InputParameter("边界类型")]
        public BorderTypes BorderTypes { get; set; } = BorderTypes.Reflect101;
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Mat mat1 = new Mat();
            Cv2.Blur(mat, mat1, KSize,Anchor,BorderTypes);
            return ResultData<Mat>.Accept(TextResource.blur_complete, mat1);

        }
    }

}
